<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

</head>
<body>
<c:set var="path" value="${pageContext.request.contextPath}"/>
	<div class="default-padding container-fluid">
		<div class="page-header">
		  <h3>通过此功能来管理用户，包括用户基本信息、头像、角色等</h3>
		</div>
		<button type="button" onclick="addUser()" class="btn btn-primary default-margin-bottom">新增用户</button>
		<table class="table table-bordered table-hover user-table">
			<thead>
				<tr>
					<th>序号</th>
					<th>头像</th>
					<th>用户名</th>
					<th>昵称</th>
					<th>注册时间</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
		    <c:forEach items="${dataUsers }" var="dUser" varStatus="status">
		    	<tr>
		    		<td>${status.count }</td>
		    		<td>
		    		<c:choose>
		    		<c:when test="${empty dUser.headIcon }">
		    			<img class="head-icon" src="${path }/images/user_default_photo.jpg"/>
		    		</c:when>
		    		<c:otherwise>
		    			<img class="head-icon" src="${path }/upload/${dUser.headIcon}"/>
		    		</c:otherwise>
		    		</c:choose>
		    		</td>
		    		<td>${dUser.username }</td>
		    		<td>${dUser.nickName }</td>
		    		<td><fmt:formatDate value="${dUser.registerDate }"   pattern="yyyy-MM-dd hh:mm:ss" type="date" dateStyle="long" /></td>
		    		<td>
		    			<button type="button" onclick="editUser('${dUser.id}')" class="btn btn-info">修改</button>
		    			<button type="button" onclick="deleteUser('${dUser.id}')" class="btn btn-warning">删除</button>
		    		</td>
		    	</tr>
	    	</c:forEach>
			</tbody>
		</table>
	</div>
	<script type="text/javascript">
	function deleteUser(userId){
		var submit = function (v, h, f) {
		    if (v == 'ok')
		    	ajaxDataPost("/adminUser/deleteUser",{userId:userId},refreshAdmin,function(){});
		    return true; //close
		};
		$.jBox.confirm("确定删除该用户吗？", "提示", submit);
	}
	function addUser(){
		refreshTab('/adminUser/editUser');
	}
	function editUser(userId){
		refreshTab('/adminUser/editUser?userId='+userId);
	}
	</script>
</body>
</html>